package cn.milai.amtc.step3;

import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;

import cn.milai.amtc.Audio;

/**
 * 使用单独的音频播放线程播放所有音频 -> 不同音频之间切换间隔明显，无法同一时刻播放多个音频
 */
public class AudioManager {

	private static final int PER_FRAMES = 16;

	private static Queue<Audio> audios = new ConcurrentLinkedQueue<Audio>();

	static {
		new Thread() {
			public void run() {
				while (true) {
					{
						for (Audio a : audios) {
							if (a.isComplete()) {
								audios.remove(a);
							} else {
								a.play(PER_FRAMES);
							}
						}
					}
				}
			};
		}.start();
	}

	public static void add(Audio audio) {
		audios.add(audio);
	}

	public static void play() {
	}
}
